home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0711.dms / q0711.adf / Graphics / 3D / 3D.h < prev    next >
C/C++ Source or Header  |  1992-07-29  |  4KB  |  197 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Manual (ACM) V3.0            Amiga C Club (ACC) */
  4. /* -------------------------            ------------------ */
  5. /*                                                         */
  6. /* Chapter: 3D                          Amiga C Club       */
  7. /* File:    3D.h                        Tulevagen 22       */
  8. /* Author:  Mats & Anders Bjerin        181 41  LIDINGO    */
  9. /* Date:    92-04-02                    SWEDEN             */
  10. /* Version: 1.00                                           */
  11. /*                                                         */
  12. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  13. /*                                                         */
  14. /* Registered members may use this program freely in their */
  15. /*     own commercial/noncommercial programs/articles.     */
  16. /*                                                         */
  17. /***********************************************************/
  18.  
  19.  
  20. #include <exec/types.h>
  21.  
  22.  
  23. /* Factor to multiply with to reach specfloat format. */
  24. /* This gives 5 decimal places and an integer part    */
  25. /* of 16 bits i.e. numbers between -32768 and 32767.  */
  26. #define FFACTOR 65536L
  27.  
  28.  
  29. /* No steps to shift a number to make it into specfloat format. */
  30. /* Must remain 16 for function LongFloatMultiply() to work.     */
  31. #define FSHIFT 16
  32.  
  33.  
  34. /* A very small value used when something almost zero. */
  35. #define EPSILON 4
  36.  
  37.  
  38. /* So we do not have to calculate this: */
  39. #define HALF_PI           1.57080 /* 0.5 * PI */
  40. #define ONE_AND_A_HALF_PI 4.71239 /* 1.5 * PI */
  41.  
  42. /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
  43. /* that the x-axis is found.                            */
  44. #define XAXISPOS 3
  45.  
  46. /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
  47. /* that the y-axis is found.                            */
  48. #define YAXISPOS 2
  49.  
  50. /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
  51. /* that the z-axis is found.                            */
  52. #define ZAXISPOS 1
  53.  
  54. /* Number of index positions in the plane data from TOTAL_NUMBER_OF_VECTORS */
  55. /* that the 0-point (rotation) is found.                */
  56. #define ZEROPOINTPOS 4
  57.  
  58.  
  59.  
  60. /* Typedeclarations. */
  61. struct Coord3D
  62. {
  63.   long x;
  64.   long y;
  65.   long z;
  66. };
  67.  
  68. /* Useful macros to convert between radians (0-2PI) */
  69. /* and ordinary degrees (0-360):                    */
  70. #define DEG2RAD(d) ((d)/180*PI)
  71. #define RAD2DEG(r) ((r)*180/PI)
  72.  
  73.  
  74.  
  75.  
  76. /*********************************************/
  77. /* Declare all functions in the main module: */
  78. /*********************************************/
  79.  
  80. void draw_vectors
  81. (
  82.   struct RastPort *rp,
  83.   struct Coord3D data[],
  84.   WORD colour
  85. );
  86.  
  87. void Play( void );
  88.  
  89. void main();
  90.  
  91. void clean_up( STRPTR message );
  92.  
  93.  
  94.  
  95.  
  96. /*******************************************/
  97. /* Declare all functions in the 3D module: */
  98. /*******************************************/
  99.  
  100. long LongFloatMultiply( long x, long y );
  101.  
  102. long Dot3DProduct( struct Coord3D point1, struct Coord3D point2 );
  103.  
  104. void VectorProduct
  105. (
  106.   struct Coord3D a,
  107.   struct Coord3D b,
  108.   struct Coord3D *v
  109. );
  110.  
  111. int SurfaceDirection
  112. (
  113.   struct Coord3D point1,
  114.   struct Coord3D point2,
  115.   struct Coord3D point3,
  116.   struct Coord3D e
  117. );
  118.  
  119. float Angle
  120. (
  121.   long x,
  122.   long y
  123. );
  124.  
  125. void Calc3DTranslation
  126. (
  127.   long tx,
  128.   long ty,
  129.   long tz,
  130.   long a[][4]
  131. );
  132.  
  133. void Calc3DRot
  134. (
  135.   int m,
  136.   float fan,
  137.   long a[][4]
  138. );
  139.  
  140. void Calc3DMult
  141. (
  142.   long a[][4],
  143.   long b[][4],
  144.   long c[][4]
  145. );
  146.  
  147. void Generat3DRotation
  148. (
  149.   float an,
  150.   struct Coord3D b,
  151.   struct Coord3D d,
  152.   long a[][4]
  153. );
  154.  
  155. void Transform
  156. (
  157.   struct Coord3D v,
  158.   long a[][4],
  159.   struct Coord3D *w
  160. );
  161.  
  162. void CalcObserverPosition
  163. (
  164.   struct Coord3D eye,
  165.   struct Coord3D direction,
  166.   long q[][4]
  167. );
  168.  
  169. void ProjectInPerspective
  170. (
  171.   struct Coord3D v,
  172.   struct Coord3D *w,
  173.   int half_display_width,
  174.   int half_display_height
  175. );
  176.  
  177. void CalcDirection
  178. (
  179.   struct Coord3D b1,
  180.   struct Coord3D b2,
  181.   struct Coord3D *d
  182. );
  183.  
  184. void InitializeGlobalData( void );
  185.  
  186. void Prepare3DData
  187. (
  188.   int total_nr_vectors,
  189.   int zero_point_pos
  190. );
  191.  
  192. void Startup3D
  193. (
  194.   int total_nr_vectors,
  195.   int zero_point_pos
  196. );
  197.